package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.model.bean.TrainingUnDoneListResponse

/**
 * @author:hxw
 * @date  :2023/1/5
 * @desc  :
 */
class TrainingUnDoneAdapter(data: ArrayList<TrainingUnDoneListResponse.InfoList>) :
    BaseQuickAdapter<TrainingUnDoneListResponse.InfoList, BaseViewHolder>(R.layout.item_training_un_done_list, data) {

    //    @RequiresApi(Build.VERSION_CODES.M)
    override fun convert(holder: BaseViewHolder, item: TrainingUnDoneListResponse.InfoList) {
        item.run {
            holder.setText(R.id.tv_item_training_un_done_pass_name, item.passName)
            holder.setText(
                R.id.tv_item_training_un_done_pass_time,
                context.getString(R.string.fragment_mine_train_fly_detail_info_fly_time) + " " + item.flyTime
            )

            var statusContent = ""
            var statusColor = context.resources.getColor(R.color.color_8F8F8F)
            var statusIcon = R.mipmap.racing_grey
            if (item.passType == 1) { //正赛
                when (item.passStatus) {
                    1 -> {
                        statusContent = context.getString(R.string.train_fly_detail_detail_fragment_not_start)//"未开始"
                        statusIcon = R.mipmap.racing_blue
                        statusColor = context.resources.getColor(R.color.race_blue)
                    }

                    2 -> {
                        statusColor = context.resources.getColor(R.color.race_orange)
                        statusContent = context.getString(R.string.study_in_finland)
                        statusIcon = R.mipmap.racing_orange
                    }

                    4 -> {
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusContent = context.getString(R.string.Pigeons_gathering)
                        statusIcon = R.mipmap.racing_blue
                    }

                    3 -> {
                        statusColor = context.resources.getColor(R.color.race_grey)
                        statusContent = context.getString(R.string.Registration_closed)
                        statusIcon = R.mipmap.racing_grey
                    }

                    5 -> {
                        statusColor = context.resources.getColor(R.color.race_grey)
                        statusContent = context.getString(R.string.End_of_collection)
                        statusIcon = R.mipmap.racing_grey
                    }

                    7 -> {
                        statusContent = context.getString(R.string.end_of_game)
                        statusColor = context.resources.getColor(R.color.race_grey)
                        statusIcon = R.mipmap.racing_grey
                    }

                    10 -> {
                        statusContent = context.getString(R.string.finished)
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusIcon = R.mipmap.racing_grey
                    }

                    6 -> {
                        statusContent = context.getString(R.string.in_the_game)
                        statusColor = context.resources.getColor(R.color.race_red)
                        statusIcon = R.mipmap.racing_red
                    }

                    8 -> {
                        statusContent = context.getString(R.string.train_fly_detail_detail_fragment_not_started)
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusIcon = R.mipmap.racing_blue
                    }

                    9 -> {
                        statusContent = context.getString(R.string.est_pigeon_centring)
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusIcon = R.mipmap.racing_blue
                    }
                }
            } else {
                when (item.passStatus) {
                    1 -> {
                        statusContent = context.getString(R.string.item_train_fly_main_list_not_start)
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusIcon = R.mipmap.training_blue
                    }

                    2 -> {
                        statusContent = context.getString(R.string.study_in_finland)
                        statusColor = context.resources.getColor(R.color.race_orange)
                        statusIcon = R.mipmap.training_orange
                    }

                    3 -> {
                        statusContent = context.getString(R.string.Registration_closed)//"报名结束"
                        statusColor = context.resources.getColor(R.color.race_grey)
                        statusIcon = R.mipmap.training_grey
                    }

                    5 -> {
                        statusContent = context.getString(R.string.End_of_collection)//"集鸽结束"
                        statusColor = context.resources.getColor(R.color.race_grey)
                        statusIcon = R.mipmap.training_grey
                    }

                    7 -> {
                        statusContent = context.getString(R.string.end_of_game)//"比赛结束"
                        statusColor = context.resources.getColor(R.color.race_grey)
                        statusIcon = R.mipmap.training_grey
                    }

                    10 -> {
                        statusContent = context.getString(R.string.finished)//"结束中"
                        statusColor = context.resources.getColor(R.color.race_grey)
                        statusIcon = R.mipmap.training_grey
                    }

                    6 -> {
                        statusContent = context.getString(R.string.in_the_game)//"比赛中"
                        statusColor = context.resources.getColor(R.color.race_red)
                        statusIcon = R.mipmap.training_red
                    }

                    4 -> {
                        statusContent = context.getString(R.string.Pigeons_gathering)//"集鸽中"
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusIcon = R.mipmap.training_blue
                    }

                    8 -> {
                        statusContent = context.getString(R.string.train_fly_detail_detail_fragment_not_started)//"开始中"
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusIcon = R.mipmap.training_blue
                    }

                    9 -> {
                        statusContent = context.getString(R.string.est_pigeon_centring)//"验鸽中"
                        statusColor = context.resources.getColor(R.color.race_blue)
                        statusIcon = R.mipmap.training_blue
                    }

                    else -> {}
                }
            }
            holder.setText(R.id.tv_status, statusContent)
            holder.setBackgroundResource(R.id.tv_item_training_un_done_pass_img, statusIcon)
            holder.setTextColor(R.id.tv_status, statusColor)
        }
    }
}